package com.example.contestsystem.Dao;

import com.example.contestsystem.Entity.Contest;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;

import java.util.List;

public interface ContestRepository extends JpaRepository<Contest, Integer> {
    /*
     * 此接口仅需提供返回contest对象的抽象方法
     */

    Contest findByContestId(String contestId);
    Contest findByContestName(String contestName);
    Contest findByContestIdAndTeacherAccount(String contestId, int teacherAccount);
    List<Contest> findByIsValid(int mark);

    List<Contest> findByTeacherAccount(int teacherAccount);

    @Modifying
    @Transactional
    void deleteByContestId(String contestId);
}
